package com.sxx.mall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther: sunxx
 * @Date: 2024/7/27 - 07 - 27 - 1:08
 * @Description: com.sxx.mall.search.config
 * @version: 1.0
 */
@Configuration
public class MallElasticSearchConfiguration {
    public static final RequestOptions COMMON_OPTIONS;

    static {
        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
/*        builder.addHeader("Authorization", "Bearer " + TOKEN);
        builder.setHttpAsyncResponseConsumerFactory(
                new HttpAsyncResponseConsumerFactory
                        .HeapBufferedResponseConsumerFactory(30 * 1024 * 1024 * 1024));*/
        COMMON_OPTIONS = builder.build();
    }

    RestHighLevelClient client = new RestHighLevelClient(
            RestClient.builder(
                    new HttpHost("106.54.211.106", 9200, "http"),
                    new HttpHost("106.54.211.106", 9201, "http")));


/*
    @Bean
    public RestHighLevelClient restHighLevelClient(){
        RestClientBuilder builder = RestClient.builder(new HttpHost("42.193.107.233", 9200, "http"));
        RestHighLevelClient client = new RestHighLevelClient(builder);
        return client;
    }
*/

}
